package com.itheima.Test;

import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Test003 {
    public static void main(String[] args) throws IOException {
        /*

	    2. 定义测试类，编写main()方法：
		//1.定义一个集合
		List<Student> stuList = new ArrayList<>();
		stuList.add(new Student(“张三”,”男”,20,88);
		stuList.add(new Student(“李四”,”女”,19,99);
	    3. 遍历这个集合，将每个Student对象中的数据按以下格式写到项目根目录下
	  的student.txt中：
		张三,男,20,88
		李四,女,19,99
         */
        List<Student> stuList = new ArrayList<>();
        stuList.add(new Student("张三",'男',20,88));
        stuList.add(new Student("李四",'女',19,99));
        FileWriter fw  = new FileWriter("Day16codes\\aaa\\123.txt");
        for (Student stu : stuList) {

            fw.write(stu.getName()+",");
            fw.write(stu.getSex()+",");
            fw.write(stu.getAge()+",");
            fw.write(stu.getScore()+"");
            fw.write("\n");
        }
        fw.close();


    }
}
